home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
ov143b.zip
/
STRING.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-04
|
1KB
|
62 lines
/* 005 8-Jun-87 string.c
Common string related functions.
Copyright (c) 1987 by Blue Sky Software. All rights reserved.
*/
#ifndef NULL
#define NULL (0)
#endif
#ifdef LINT_ARGS
#include <memory.h>
#endif
/*****************************************************************************
C A T N S T R
*****************************************************************************/
char *
catnstr(s1,s2,max) /* concat s2 to s1 (or as much as will fit) */
char *s1, *s2;
int max;
{
int l1, l2;
if ((l1 = strlen(s1)) + (l2 = strlen(s2)) <= max)
strcat(s1,s2);
else
if (l1 < max)
strncat(s1,s2,max-l1);
return(s1);
}
/*****************************************************************************
S T R C P Y F I L L
*****************************************************************************/
char *
strcpyfill(to,from,fldlen,fillch) /* copy a string with char fill */
char *from;
register char *to;
int fldlen, fillch;
{
char *to_where;
register int len;
to_where = to;
len = strlen(from);
if (len < fldlen) {
strncpy(to,from,len);
memset(to+len,fillch,fldlen-len);
} else
strncpy(to,from,fldlen);
return(to_where);
}